package com.application.mission.manage;

import java.util.Date;
import java.util.TimerTask;

import org.apache.log4j.Logger;

import com.application.actor.manage.ActorManage;
import com.application.actor.pojo.Actor;
import com.application.mission.pojo.ActorMission;

public class MissionTimer extends TimerTask {
	private Logger logger = Logger.getLogger(this.getClass());
    private int nowDay=new Date().getDay();
	@Override
	public void run() {
		Date now = new Date();
		int day = now.getDay();
		//System.out.println("flash mission at    "+new Date(System.currentTimeMillis()).toLocaleString());
		if(day!=nowDay){
			nowDay=day;
			try {
				for (ActorMission m:MissionManage.actorMissions.values()) {
					 m.daylyCompleted.clear();
					 Actor a = ActorManage.getOnlineActor(m.actorId);
					 if(a!=null){
						 MissionManage.checkMissionStatus(m.actorId);
					 }
				}
			} catch (Exception e) {
				logger.error("mission check error",e);
				//e.printStackTrace();
			}
		}
	}

	 

}
